package com.cgtong.android.mvp.presenter;

import com.cgtong.android.bean.AdviseBean;
import com.cgtong.android.mvp.contract.GetAdviseContract;
import com.cgtong.android.mvp.model.GetAdviseModel;
import com.zhouyou.http.callback.SimpleCallBack;
import com.zhouyou.http.exception.ApiException;

import java.util.List;

/**
 * Created by Tinwai on 2017/10/25.
 */
public class GetAdvisePresenter implements GetAdviseContract.Presenter {
    private GetAdviseContract.View mView;
    private GetAdviseModel model;

    public GetAdvisePresenter(GetAdviseContract.View mView) {
        this.mView = mView;
        this.model = new GetAdviseModel();
    }


    @Override
    public void getAdviseList() {
        model.getAdviseList(new SimpleCallBack<List<AdviseBean>>() {
            @Override
            public void onError(ApiException e) {
                mView.setNullData();
            }

            @Override
            public void onSuccess(List<AdviseBean> list) {
                if (list == null || list.size() == 0) {
                    mView.setNullData();
                } else {
                    mView.setDatas(list);
                }
            }
        });
    }
}
